<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        const reg = /123/;

        // 常用的
        console.log(reg.test('123456'));
        console.log(reg.test('3445'));
        console.log(reg.test('abc'));

        console.log(reg.exec('123456'));
        console.log(reg.exec('zzz'));

        const str = 'hello world';
        console.log(str.match(reg));


        // const phones = `
        //     张三: 18812341234;
        //     李遂: 18812341236;
        // `;
        // const reg = /1[3|4|5|7|8]\d{9}/g;

        // const res = phones.replace(reg, '***********');
        // console.log(res);

        // console.log(phones.match(reg));


        // 替换数字
        // const str1 = 'dfgfg14f56 ff 848';
        // const res = str1.replace(/\d/g, '+');
        // console.log(res);

        // 替换空格
        // const str2 = 'dfgfg14f56 ff 848';
        // const res1 = str2.replace(/\s/g, '-');
        // console.log(res1);
    </script>
</body>
</html> 